#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n;
int tr[N * 20][26], ed[N * 20], h[N * 20], num;
void insert(string s) {
  int p = 0;
  for (char c : s) {
    int ch = c - 'a';
    if (!tr[p][ch]) tr[p][ch] = ++num;
    p = tr[p][ch];
  }
  ed[p] = 1;
}
void dfs(int u) {
  h[u] = 1;
  rep(v, 0, 25) {
    if (tr[u][v]) {
      dfs(tr[u][v]);
      h[u] = max(h[u], h[tr[u][v]] + 1);
    }
  }
}
vector<char> ans;
int len = 0;
bool cmp(pii a, pii b) { return a.first < b.first; }
void dfs2(int u) {
  if (ed[u]) ans.push_back('P'), len = ans.size();
  vector<pii> ch;
  rep(v, 0, 25) if (tr[u][v]) ch.push_back(pii(h[tr[u][v]], v));
  sort(ch.begin(), ch.end(), cmp);
  for (pii x : ch) {
    char c = x.second + 'a';
    ans.push_back(c);
    dfs2(tr[u][x.second]);
    ans.push_back('-');
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) {
    string s;
    cin >> s;
    insert(s);
  }
  dfs(0);
  dfs2(0);
  while (ans.size() && ans.back() == '-') ans.pop_back();
  cout << ans.size() << endl;
  for (char c : ans) cout << c << endl;
  return 0;
}